//select the correct radio button
function selectRadioButton(status)
{
    if(status == 2)
    {
        document.getElementById('radio_suspend_id').checked = true;
    }
    else
    {
        document.getElementById('radio_resume_id').checked = true;
    }
};

//--------------------------------------------------------------------------------------------------------------------
// suspends the betroom transactions
function suspendTransactions(betroomName)
{
    var args = { 
           type: "POST", 
           url: "/admin2/suspend/",
           cache: false,
           data: { 'betroom' : betroomName }, 
           complete:function(res)  { window.location.reload(); },
           error: function(errorThrown)  { document.write(errorThrown.responseText);  }
           };
    $.ajax(args);
    return false;  
};

//--------------------------------------------------------------------------------------------------------------------
// resumes the betroom transactions
function resumeTransactions(betroomName)
{
    var args = { 
           type: "POST", 
           url: "/admin2/resume/",
           cache: false,
           data: { 'betroom' : betroomName }, 
           complete:function(res) { window.location.reload(); },
           error: function(errorThrown)  { document.write(errorThrown.responseText);  }
           };
    $.ajax(args);
    return false;  
};

//--------------------------------------------------------------------------------------------------------------------
// resize the text area
function resize0(textarea)
{ 
	var txt = textarea.value;
	var line = txt.split("\n");
	var nbr_lines = 1;
	for(var i=0;i<line.length;i++)
	{
		nbr_lines += Math.ceil(line[i].length / (textarea.cols + 7));
	}
	textarea.rows = nbr_lines;
	return false;
};
 
//--------------------------------------------------------------------------------------------------------------------
// send an email to the player in the betroom
function sendEmail()
{
    var object0 = document.getElementById( "id_mail_object" ).value;
    if( object0 == '' )
    {
        alert('Please enter an object to the email.');
        return  false;
    }
    var text0 = document.getElementById( "id_mail_text" ).value;
    if( text0 == '' )
    {
        alert('Please type a body to the email.');
        return  false;
    }
    var test1 = confirm('An email will be sent to all the players. Please consider that this could be annoying. Do you want to continue?');
	if( test1 )
	{
	    submitWithReload(
        "/admin2/send_email/",
        { 'email_object' : object0, 'email_text':text0 },
        'message has been successfully sent.'
        );
        document.getElementById( "id_mail_object" ).value ="";
        document.getElementById( "id_mail_text" ).value ="";
	}
	return false;
}
 


